package com.zc.syn;

import com.zc.common.Constant;
import com.zc.common.Shop;
import org.springframework.util.StopWatch;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

/**
 * 同步的方式
 * 2019年12月15日 02:32:53
 */
public class SynTest {

    public static void main(String[] args) throws Exception {

        Vector<Integer> results = new Vector<>();

        List<Shop> synShops = new ArrayList<>();


        for (int i = 1; i <= Constant.COUNT; i++) {
            synShops.add(new Shop());
        }

        StopWatch stopWatch = new StopWatch();

        stopWatch.start();

        synShops.forEach(synShop -> results.add(synShop.sleep()));

        stopWatch.stop();

        System.out.println("花费总时间 totalTime = " + stopWatch.getTotalTimeMillis());
        System.out.println("返回结果总条数为 totalCount = " + results.size());
        System.out.println("返回结果结果为  results = " + results.toString());


    }
}
